package com.div.tools.viewpager

import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter
import java.util.*

class ViewPagerAdapter(list: ArrayList<View>) : PagerAdapter() {

    var mList: List<View>? = list
    override fun isViewFromObject(view: View, `object`: Any): Boolean {
        return view == `object`
    }

    override fun getCount(): Int {
        return mList?.size?: 0
    }

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        val view = mList?.get(position) as View
        container.addView(view)
        return view
    }
    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        container.removeView(mList?.get(position))
    }
}
